package com.nd.config;

import org.apache.commons.lang.StringUtils;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;


import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;

//获取JSessionID
public class AdminSessionManager extends DefaultWebSessionManager {

    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse resp = (HttpServletResponse) response;
        String sessionId = req.getHeader("X-cskaoyan-mall-Admin-Token");
        if(!StringUtils.isBlank(sessionId)) return sessionId;
        return super.getSessionId(req, resp);
    }
}
